#include "../common/detail.hpp"
#include "../server/rpc_server.hpp"

void Add(const Json::Value &req, Json::Value &rsp)
{
    int num1 = req["num1"].asInt();
    int num2 = req["num2"].asInt();
    rsp = num1 + num2;
}

int main()
{
    //auto router = std::make_shared<rpc::server::RpcRouter>();
    std::unique_ptr<rpc::server::SDescribeFactory> desc_factory(new rpc::server::SDescribeFactory());
    desc_factory->setMethodName("Add");
    desc_factory->setParamsDesc("num1", rpc::server::VType::INTEGRAL);
    desc_factory->setParamsDesc("num2", rpc::server::VType::INTEGRAL);
    desc_factory->setReturnType(rpc::server::VType::INTEGRAL);
    desc_factory->setServiceCallBack(Add);
    //router->registerMethod(desc_factory->build());

    rpc::server::RpcServer server(rpc::Address("127.0.0.1", 9090), rpc::Address("127.0.0.1", 8080), true);
    server.registerMethod(desc_factory->build());
    server.start();

    return 0;
}